<template>
  <div class="main-stream">
    <video ref="teacherVideo" autoplay></video>
    <div class="stream-info">
      <div class="user-info">
        <span class="name">{{ roomInfo.teacherName }}</span>
        <span class="status">主讲</span>
      </div>
      <div class="controls">
        <button class="control-btn">
          <el-icon><Microphone /></el-icon>
        </button>
        <button class="control-btn">
          <el-icon><VideoCamera /></el-icon>
        </button>
        <button class="control-btn">
          <el-icon><Share /></el-icon>
        </button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";

defineProps({
  roomInfo: Object,
});
const teacherVideo = ref(null);

// 设置视频流
const setVideoStream = (stream) => {
  teacherVideo.value.srcObject = stream;
};
defineExpose({
  setVideoStream,
});
</script>

<style lang="scss" scoped>
.main-stream {
  flex: 1;
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;

  video {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .stream-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    box-sizing: border-box;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));

    .user-info {
      display: flex;
      align-items: center;
      gap: 12px;

      .name {
        font-size: 16px;
        color: #fff;
        font-weight: 500;
      }

      .status {
        padding: 2px 8px;
        background: rgba(64, 128, 255, 0.2);
        border: 1px solid rgba(64, 128, 255, 0.4);
        color: #4080ff;
        font-size: 12px;
        border-radius: 4px;
      }
    }

    .controls {
      display: flex;
      gap: 12px;

      .control-btn {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        border-radius: 8px;
        color: #fff;
        cursor: pointer;
        transition: all 0.3s;

        .el-icon {
          font-size: 20px;
        }

        &:hover {
          background: rgba(255, 255, 255, 0.2);
        }

        &.active {
          background: rgba(64, 128, 255, 0.2);
          color: #4080ff;
        }

        &:active {
          transform: scale(0.95);
        }
      }
    }
  }
}
</style>
